package com.top75;

import java.util.LinkedList;

/**
 * @Author: huangzhigao
 * @Date: 2023/5/14 18:43
 */
public class Code643 {
    public static double findMaxAverage(int[] nums, int k) {
        double res = Integer.MIN_VALUE;
        double sum = 0;
        for (int i = 0; i < nums.length; i++) {
            sum = sum + nums[i];
            if (i + 1 >= k) {
                res = Math.max(res, sum / (double)k);
                sum = sum - nums[i + 1 - k];
            }
        }
        return res;
    }

    public static void main(String[] args) {
        int[] num = {-1};
        System.out.println(findMaxAverage(num, 1));
    }
}
